package com.hermit.qmst.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.hermit.qmst.R;
import com.hermit.qmst.mode.MessageInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/10/20 0020.
 */
public class OfficialAdapter extends BaseAdapter {

    public List<MessageInfo> data;
    private Context context;

    public OfficialAdapter(Context context) {
        data = new ArrayList<MessageInfo>();
        this.context = context;
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Holder holder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_officia, null);
            holder =new Holder();
            holder.tv_title = (TextView) convertView.findViewById(R.id.tv_title);
            holder.tv_time = (TextView) convertView.findViewById(R.id.tv_time);

            convertView.setTag(holder);
        } else {
            holder = (Holder) convertView.getTag();
        }
        holder.tv_title.setText(data.get(position).getTitle());
        holder.tv_time.setText(data.get(position).getCreatetime());
        return convertView;
    }

    class Holder {
        TextView tv_title, tv_time;
    }
}
